﻿SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
GO
CREATE TABLE dbo.bht_PayU_PaymentTransactionLog
	(
	LogId int NOT NULL IDENTITY (1, 1),
	TransactionId int,
	PosId int NOT NULL,
	PosAuthKey nchar(7) NOT NULL,
	PaymentType nvarchar(10) NOT NULL,
	ChargeValue numeric(12, 2) NOT NULL,
	Description nvarchar(50) NOT NULL,
	FirstName nvarchar(100) NOT NULL,
	LastName nvarchar(100) NOT NULL,
	EMail nvarchar(100) NOT NULL,
	ClientIP nvarchar(15) NOT NULL,
	[Status] int NOT NULL,
	SessionId nvarchar(50) NOT NULL,
	OrderID int NULL,
	Description2 nvarchar(1024) NULL,
	DescriptionBank nvarchar(27) NULL,
	Street nvarchar(10) NULL,
	StreetNumber nvarchar(10) NULL,
	FlatNumber nvarchar(10) NULL,
	City nvarchar(100) NULL,
	PostCode nvarchar(20) NULL,
	Country nvarchar(100) NULL,
	Phone nvarchar(100) NULL,
	Language char(10) NULL,
	JavaScript bit NULL,
	PaybackLogin nvarchar(40) NULL,
	Sig nvarchar(32) NULL,
	Ts nvarchar(1000) NULL,
	LogTime DATETIME
	)  ON [PRIMARY]
GO
ALTER TABLE dbo.bht_PayU_PaymentTransactionLog ADD CONSTRAINT
	DF_bht_PayU_PaymentTransactionLog_LogTime DEFAULT GETDATE() FOR LogTime
GO
ALTER TABLE dbo.bht_PayU_PaymentTransactionLog ADD CONSTRAINT
	PK_bht_PayU_PaymentTransactionLog PRIMARY KEY CLUSTERED 
	(
	LogId
	) ON [PRIMARY]

GO
ALTER TABLE dbo.bht_PayU_PaymentTransactionLog ADD CONSTRAINT
	FK_bht_PayU_PaymentTransactionLog_bht_PayU_PaymentType FOREIGN KEY
	(
	PaymentType
	) REFERENCES dbo.bht_PayU_PaymentType
	(
	PaymentKey
	) ON UPDATE  NO ACTION 
	 ON DELETE  NO ACTION 
	
GO
ALTER TABLE dbo.bht_PayU_PaymentTransactionLog ADD CONSTRAINT
	FK_bht_PayU_PaymentTransactionLog_bht_PayU_PaymentStatus FOREIGN KEY
	(
	Status
	) REFERENCES dbo.bht_PayU_PaymentStatus
	(
	StatusId
	) ON UPDATE  NO ACTION 
	 ON DELETE  NO ACTION 
	
GO
ALTER TABLE dbo.bht_PayU_PaymentTransactionLog ADD CONSTRAINT
	FK_bht_PayU_PaymentTransactionLog_bht_PayU_PaymentTransaction FOREIGN KEY
	(
	[TransactionId]
	) REFERENCES dbo.bht_PayU_PaymentTransaction
	(
	TransactionId
	) ON UPDATE  NO ACTION 
	 ON DELETE  NO ACTION 
	
GO
CREATE PROCEDURE [dbo].[bhp_PayU_PaymentTransactionLog] (
	@TransactionId int,
	@PosId int,
	@PosAuthKey nchar(7),
	@PaymentType nvarchar(10),
	@ChargeValue numeric(12, 2),
	@Description nvarchar(50),
	@FirstName nvarchar(100),
	@LastName nvarchar(100),
	@EMail nvarchar(100),
	@ClientIP nvarchar(15),
	@Status int,
	@OrderID int,
	@Description2 nvarchar(1024),
	@DescriptionBank nvarchar(27),
	@Street nvarchar(10),
	@StreetNumber nvarchar(10),
	@FlatNumber nvarchar(10),
	@City nvarchar(100),
	@PostCode nvarchar(20),
	@Country nvarchar(100),
	@Phone nvarchar(100),
	@Language char(10),
	@JavaScript bit,
	@PaybackLogin nvarchar(40),
	@Sig nvarchar(32),
	@Ts nvarchar(1000),
	@SessionId nvarchar(50)
)
AS
BEGIN
	INSERT INTO bht_PayU_PaymentTransactionLog (
		[TransactionId],
		[PosId],
		[PosAuthKey],
		[PaymentType],
		[ChargeValue],
		[Description],
		[FirstName],
		[LastName],
		[EMail],
		[ClientIP],
		[Status],
		[OrderID],
		[Description2],
		[DescriptionBank],
		[Street],
		[StreetNumber],
		[FlatNumber],
		[City],
		[PostCode],
		[Country],
		[Phone],
		[Language],
		[JavaScript],
		[PaybackLogin],
		[Sig],
		[Ts],
		[SessionId]
	) VALUES (
		@TransactionId,
		@PosId,
		@PosAuthKey,
		@PaymentType,
		@ChargeValue,
		@Description,
		@FirstName,
		@LastName,
		@EMail,
		@ClientIP,
		@Status,
		@OrderID,
		@Description2,
		@DescriptionBank,
		@Street,
		@StreetNumber,
		@FlatNumber,
		@City,
		@PostCode,
		@Country,
		@Phone,
		@Language,
		@JavaScript,
		@PaybackLogin,
		@Sig,
		@Ts,
		@SessionId
	)
	
	SELECT @@IDENTITY as LogId
END
GO